package LambdaRepresentation;

class Student{
    private String name = "bit";
    public int age = 19;
    public Student(){
        System.out.println("Student()");
    }

    private Student(String name , int age){
        this.name = name;
        this.age = age;
        System.out.println("Student(String name)");
    }

    private void eat(){
        System.out.println("i am eat");
    }

    public void sleep(){
        System.out.println(" you are a pig");
    }

    private void function(String str){
        System.out.println(str);
    }

    public String toString(){
        return "Student{"+
                "name = "+name+"\'"+
                ",age"+age+")";
    }
}

public class Test {
    public static void main(String[] args) {
        //获取class对象的三种方法:
        //①
        Class<?> c1 = null;
        try{
            c1 = Class.forName("LambdaRepresentation.Student");   //因为这个类他在src底下的包里,所以要加上包名,否则会报错
        }catch (ClassNotFoundException e){
            e.printStackTrace();
        }

        //②
        Class c2 = Student.class;

        //③
        Student student = new Student();
        Class c3 = student.getClass();

        System.out.println(c1.equals(c2));
        System.out.println(c1.equals(c3));
        System.out.println(c2.equals(c2));
    }

}
